from flask_sqlalchemy import SQLAlchemy
import datetime

# 创建数据库实例
db = SQLAlchemy()

class TTSTransformation(db.Model):
    """文字转声音转换记录模型"""
    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.Text, nullable=False)
    voice = db.Column(db.String(50), nullable=False)
    speed = db.Column(db.Float, default=1.0)
    duration = db.Column(db.Float, nullable=False)  # 处理时间（秒）
    timestamp = db.Column(db.DateTime, nullable=False, default=datetime.datetime.now)
    
    def __repr__(self):
        return f'<TTSTransformation {self.id}: {self.text[:30]}...>'